/**
 * 	write on 2005-10-26 11:49:25.
 */
package org.nanhill.xmlro.sro;

import static org.nanhill.xmlro.sro.SroConstants.SRO_END;

import org.nanhill.xmlro.AbstractXmlroTransport;
import org.nanhill.xmlro.SerializerFactory;
import org.nanhill.xmlro.XmlroInput;
import org.nanhill.xmlro.XmlroOutput;
import org.nanhill.xmlro.sro.model.SroSerializerFactory;

/**
 * Sro transport.
 * 
 * This class is thread safe.
 * 
 * @author alin
 * 
 */
public class SroTransport extends AbstractXmlroTransport {

	private static final SerializerFactory DEFAULT_SERIALIZER_FACTORY = new SroSerializerFactory();

	private SerializerFactory serializerFactory = DEFAULT_SERIALIZER_FACTORY;

	public void setSerializerFactory(SerializerFactory serializerFactory) {
		this.serializerFactory = serializerFactory;
	}

	public SerializerFactory getSerializerFactory() {
		return serializerFactory;
	}

	@Override
	protected String getEndFlag() {
		return SRO_END;
	}

	@Override
	protected XmlroOutput getOutput() {
		XmlroOutput output = new SroOutput();
		output.setSerializerFactory(this.serializerFactory);
		return output;
	}

	@Override
	protected XmlroInput getInput() {
		XmlroInput input = new SroInput();
		return input;
	}

	@Override
	protected <E> XmlroInput<E> getWrappedInput(E wrap) {
		XmlroInput<E> input = new SroInput<E>();
		if (null != wrap) {
			input.setWrap(wrap);
		}
		return input;
	}

	@Override
	protected <E> XmlroInput<E> getWrappedInput(Class<E> wrapClz) {
		XmlroInput<E> input = new SroInput<E>();
		if (null != wrapClz) {
			input.wrapClz(wrapClz);
		}
		return input;
	}

}
